﻿
//********************************************************************************//
//创建日期：<创建日期，2017-8-16>
//创建作者：sunxueting
//功能说明：回灌退费
//********************************************************************************//
layui.use(['form', 'jquery', 'element', 'laydate'], function () {
    var form = layui.form()
    , layer = layui.layer
    , $ = layui.jquery
    , element = layui.element()
    , laydate = layui.laydate;
    /*initial load start*/
    initcontrol();
    /*initial load end*/

    /*initial*/

    var Y;
    var userid = getLoginInfo().UserId;
    //alert(userid);
    function initcontrol() {
      
        //获取当前水量年月
        $.ajax({
            type: "post",
            cache: false,
            async: false,
            url: "/ashx/Common.ashx",
            data: {
                "op": "QSYM"
            },
            dataType: "json",
            success: function (rs) {
                Y = (rs.Data1 + "").substring(0, 4);
                $("#cYM").val(Y);
               
            },
            error: function (error) {
                layer.msg(error.responseText);
            }
        });
       
    }
    /*end initial*/

    /*event*/
    $("#oSearch").click(function () {
       // var index = layer.load(1);
        var strs = "";
         Y = $("#cYM").val();
        if (Y == "") {
            layer.alert("请输入水量年");
            return;
        }
        else {
           
            $.ajax({
                type: "post",
                cache: false,
                async: false,
                url: "/ashx/QSSFZW/HuiGuanTF.ashx",
                data: {
                    "op": "YHSJ",
                    "y": Y
                   
                },
                dataType: "json",
                success: function (rs) {
                    strs = rs;

                    $("#lsCount").text(rs.length);
                    $("#ContentList1 tbody").html("");
                    CreateTable_OLD(rs);
                    bindListOperat();
                    GetHJ();

                    //var id = rs[0].ID;
                    //var yhh = rs[0].S_YONGHUH;
                    //layer.alert(id + ' ' + yhh);
                
                },
                error: function (error) {
                    layer.msg(error.responseText);
                }
            });

            //$("#lsCount").text(strs.length);
            //$("#ContentList1 tbody").html("");
            //if (strs.length > 0) {
            //    chunk(strs, listCreate, null);
            //}
        }
        //layer.close(index);
    });

    function listCreate(rs, i) {
        if (i < 3) {
            CreateTable(rs);
        }

        //$("#lsCount").text($("#ContentList2 tbody").length);
    }

    function bindListOperat() {
        //行点击切换选中状态
        //setSelectedInfo("", "", "");
        $("#ContentList1 .datarow").click(function () {
            var selected = $(this).attr("selected");
            //移除之前选中项背景色及标识
            $("#ContentList1 .datarow[selected='selected']").css("background-color", "");
            $("#ContentList1 .datarow[selected='selected']").removeAttr("selected");
           
            //如果点击在已选择项上,无需继续选中
            if (selected != "selected") {
                //给当前项加标识
                $(this).attr("selected", "selected");
                $(this).css("background-color", "#a2c4ea");
                //setSelectedInfo($(this).attr("vid"), $(this).attr("vid2"), $(this).attr("vid3"));
            }
        });
    }

    window.Update = function (obj) {
        
        var yhh = $(obj).attr("yhh");
        //alert(yhh);
        //txtYhh.value = yhh;
        $("#ContentList1 tbody").find(".datarow[vid="+yhh+"]").find("input").removeProp("disabled");
          
    }

    function CreateTable(obj) {
        var itemstr = ""; var str = "";
        var id, gldw, yhh, yhm, hgdj, wtsf, ytsf, ytsf2, yhzh, khyh, jxx;
        var hgj = "", hgjh = "", jdz = "", hgl = "", nhgnl = "", xhgnl = "", cshgnl = "";
        id = obj.ID;
        gldw = obj.S_BUMENMC != null ? obj.S_BUMENMC : "";
        yhh = obj.S_YONGHUH != null ? obj.S_YONGHUH : "";
        yhm = obj.S_YONGHUM != null ? obj.S_YONGHUM : "";
        hgdj = obj.N_HUIGUANDJ != null ? obj.N_HUIGUANDJ : "";
        wtsf = obj.N_TUIFEI_W != null ? obj.N_TUIFEI_W : "";
        ytsf = obj.N_TUIFEI_Y != null ? obj.N_TUIFEI_Y : "";
        ytsf2 = obj.N_TUIFEI_Z != null ? obj.N_TUIFEI_Z : "";
        yhzh = obj.S_YHZH != null ? obj.S_YHZH : "";
        khyh = obj.S_KHHM != null ? obj.S_KHHM : "";

        //根据当前的用户查询对应的井信息
        jxx = getJXX(yhh);
        hgj = CreateJ(jxx, 1);
        hgjh = CreateJ(jxx, 2);
        jdz = CreateJ(jxx, 3);
        hgl = CreateJ(jxx, 4);
        nhgnl = CreateJ(jxx, 5);
        xhgnl = CreateJ(jxx, 6);
        cshgnl = CreateJ(jxx, 7);
        str = '<tr class="datarow" style="cursor:pointer" selected vid="' + yhh + '" >';
        str += '<td style="text-align:center"><input type="checkbox" name="liCheck" vid="' + yhh + '"  lay-skin="primary" lay-filter="liCheck"></td>';
        str += '<td>' + gldw + '</td>';
        str += '<td>' + yhm + '</td>';
        str += '<td style="text-align:center">' + yhh + '</td>';
        str += '<td>' + hgj + '</td>';
        //str += hgj;
        str += '<td>' + jdz + '</td>';
        str += '<td>' + hgjh + '</td>';
        str += '<td>' + hgl + '</td>';
        str += '<td hgdj style="text-align:right"><input autocomplete="off" style="border-style:hidden;width:55px;margin:0;padding:0;background-color:white" disabled value="' + hgdj + '"/></td>';
        str += '<td wtsf style="text-align:right"><input autocomplete="off" style="border-style:hidden;width:55px;margin:0;padding:0;background-color:white" disabled value="' + wtsf + '"/></td>';
        str += '<td ytsf style="text-align:right"><input autocomplete="off" style="border-style:hidden;width:55px;margin:0;padding:0;background-color:white" disabled value="' + ytsf + '"/></td>';
        str += '<td ytsf2 style="text-align:right"><input autocomplete="off" style="border-style:hidden;width:55px;margin:0;padding:0;background-color:white" disabled value="' + ytsf2 + '"/></td>';
        str += '<td>' + nhgnl + '</td>';
        str += '<td>' + xhgnl + '</td>';
        str += '<td>' + cshgnl + '</td>';

        str += '<td><a yhh="' + yhh + '" onclick="Update(this)">编辑</a><a yhh="' + yhh + '" onclick="Save(this)">保存</a></td>';
        str += '</tr>';
       
        $("#ContentList1 tbody").append(str);

        //$("#lsCount").text($("#ContentList1 tbody").length)
       
    }

    function CreateTable_OLD(obj) {
        var itemstr, str, id, gldw, yhh, yhm, hgdj, wtsf, ytsf, ytsf2, yhzh, khyh,zt, jxx;
        var  hgj, hgjh, jdz, hgl, nhgnl, xhgnl, cshgnl;
        for (var i = 0; i < obj.length; i++) {//obj.length
            id = obj[i].ID;
            gldw = obj[i].S_BUMENMC != null ? obj[i].S_BUMENMC : "";
            yhh = obj[i].S_YONGHUH != null ? obj[i].S_YONGHUH : "";            
            yhm = obj[i].S_YONGHUM != null ? obj[i].S_YONGHUM : "";
            hgdj = obj[i].N_HUIGUANDJ != null ? obj[i].N_HUIGUANDJ : "";
            wtsf = obj[i].N_TUIFEI_W != null ? obj[i].N_TUIFEI_W : "";
            ytsf = obj[i].N_TUIFEI_Y != null ? obj[i].N_TUIFEI_Y : "";
            ytsf2 = obj[i].N_TUIFEI_Z != null ? obj[i].N_TUIFEI_Z : "";
            yhzh = obj[i].S_YHZH != null ? obj[i].S_YHZH : "";
            khyh = obj[i].S_KHHM != null ? obj[i].S_KHHM : "";
            zt = obj[i].I_ZHUANGTAI != null ? obj[i].I_ZHUANGTAI : "0";

            //根据当前的用户查询对应的井信息
            jxx = getJXX(yhh);           
            hgj = CreateJ(jxx, 1);
            hgjh = CreateJ(jxx, 2);
            jdz = CreateJ(jxx, 3);
            hgl = CreateJ(jxx, 4);
            nhgnl = CreateJ(jxx, 5);
            xhgnl = CreateJ(jxx, 6);
            cshgnl = CreateJ(jxx, 7);

            if (zt=="1") {
                str = '<tr class="datarow" style="cursor:pointer;background-color:#f6f6f6;" selected vid="' + yhh + '" >';
                str += '<td style="text-align:center"><input type="checkbox" disabled name="liCheck" vid="' + yhh + '"   lay-skin="primary" lay-filter="liCheck"></td>';
            }
            else {
                str = '<tr class="datarow" style="cursor:pointer" vid="' + yhh + '" >';
                str += '<td style="text-align:center"><input type="checkbox" name="liCheck" vid="' + yhh + '"   lay-skin="primary" lay-filter="liCheck"></td>';
            }
            str += '<td><a yhh="' + yhh + '" onclick="Update(this)">编辑</a><a yhh="' + yhh + '" onclick="Save(this)">保存</a></td>';
           
            str += '<td>' + gldw + '</td>';
            str += '<td>' + yhm + '</td>';
            str += '<td style="text-align:center">' + yhh + '</td>';
            str += '<td>' + hgj + '</td>';
            str += '<td>' + hgjh + '</td>';
            str += '<td hgdj style="text-align:right"><input autocomplete="off" style="border-style:hidden;width:70px;margin:0;padding:0;background-color:white" disabled value="' + hgdj + '"/></td>';
            str += '<td>' + cshgnl + '</td>';
            str += '<td>' + jdz + '</td>';
            str += '<td>' + hgl + '</td>';
            str += '<td wtsf style="text-align:right"><input autocomplete="off" style="border-style:hidden;width:70px;margin:0;padding:0;background-color:white" disabled value="' + wtsf + '"/></td>';
            str += '<td ytsf style="text-align:right"><input autocomplete="off" style="border-style:hidden;width:70px;margin:0;padding:0;background-color:white" disabled value="' + ytsf + '"/></td>';
            str += '<td ytsf2 style="text-align:right"><input autocomplete="off" style="border-style:hidden;width:70px;margin:0;padding:0;background-color:white" disabled value="' + ytsf2 + '"/></td>';

            //str += '<td hgdj style="text-align:right">' + hgdj + '</td>';
            //str += '<td wtsf style="text-align:right">' + wtsf + '</td>';
            //str += '<td ytsf style="text-align:right">' + ytsf + '</td>';
            //str += '<td ytsf2 style="text-align:right">' + ytsf2 + '</td>';

            str += '<td>' + nhgnl + '</td>';
            str += '<td>' + xhgnl + '</td>';
            str += '<td yhzh style="text-align:left"><input autocomplete="off" style="border-style:hidden;width:140px;margin:0;padding:0;background-color:white" disabled value="' + yhzh + '"/></td>';
            str += '<td khyh style="text-align:left"><input autocomplete="off" style="border-style:hidden;width:140px;margin:0;padding:0;background-color:white" disabled value="' + khyh + '"/></td>';
            //str += '<td  yhid="' + yhh + '"  jid="' + hgj + '" >编辑</td>';
            str += '</tr>';
            itemstr = itemstr + str;
        }
        $("#ContentList1 tbody").append(itemstr);
        form.render("checkbox");
        //bindListOperate();
    }

    $("#ContentList1 tbody tr").each(function () {
        $(this).find("[name='liCheck']").click(function () {

        });
    });

       

   
    //保存事件
    window.Save = function (obj) {
        var yhh = $(obj).attr("yhh");
        $("#ContentList1 tbody").find(".datarow[vid=" + yhh + "]").find("input").prop("disabled", "disabled");
        //alert(yhh);
        SaveData(yhh);
        
    }

    //获取井相关数据
    function getJXX(yhh) {
        var strs = "";
        $.ajax({
            type: "post",
            cache: false,
            async: false,
            url: "/ashx/QSSFZW/HuiGuanTF.ashx",
            data: {
                "op": "JSJ",
                "y": Y,
                "yhh":yhh

            },
            dataType: "json",
            success: function (rs) {
                strs = rs;
            },
            error: function (error) {
                layer.msg(error.responseText);
            }
        });

        return strs;
    }

    //拼接井香瓜标记
    function CreateJ(obj, a) {
        var str = "", value = "";
        str = '<table style="border-style:hidden;width:100%;margin:0;">';
        
        if (a == 1) {//hgj
            for (var i = 0; i < obj.length; i++) {
                value = obj[i].S_JINGBH != null ? obj[i].S_JINGBH : " ";
                str += '<tr jh>';
                str += '<td style="text-align:center;width:100%;">' + value + '</td>';
                str += '</tr>';
            }
        }
        else if (a == 2) {//hgjh
            for (var i = 0; i < obj.length; i++) {
                value = obj[i].N_HUIGUANJH != null ? obj[i].N_HUIGUANJH : 0;
                str += '<tr hgjh>';
				str += '<td style="text-align:right;width:100%;"><input name="lihgjh" autocomplete="off" style="border-style:hidden;width:65px;margin:0;padding:0;background-color:white" disabled value="' + value + '"/></td>';
                //str += '<td style="text-align:right;width:100%;">' + value + '</td>';
                str += '</tr>';
            }
        }
        else if (a == 3) {//jdz
            for (var i = 0; i < obj.length; i++) {
                value = obj[i].S_JINGDIZ != null ? obj[i].S_JINGDIZ : '&nbsp';
                str += '<tr>';
                str += '<td style="text-align:left;width:100%;">' + value + '</td>';
                str += '</tr>';
            }
        }
        else if (a == 4) {//hgl
            for (var i = 0; i < obj.length; i++) {
                value = obj[i].I_HUIGUANL != null ? obj[i].I_HUIGUANL : 0;
                str += '<tr>';
                str += '<td hgl style="text-align:right;width:100%;">' + value + '</td>';
                str += '</tr>';
            }
        }
        else if (a == 5) {//nhgnl
            for (var i = 0; i < obj.length; i++) {
                value = obj[i].N_NHGNL != null ? obj[i].N_NHGNL : 0;
                str += '<tr>';
                str += '<td nhgnl style="text-align:right;width:100%;">' + value + '</td>';
                str += '</tr>';
            }
        }
        else if (a == 6) {//xhgnl
            for (var i = 0; i < obj.length; i++) {
                value = obj[i].N_XHGNL != null ? obj[i].N_XHGNL : 0;
                str += '<tr>';
                str += '<td xhgnl style="text-align:right;width:100%;">' + value + '</td>';
                str += '</tr>';
            }
        }
        else if (a == 7) {//cshgnl
            for (var i = 0; i < obj.length; i++) {
                value = obj[i].N_CSHGNL != null ? obj[i].N_CSHGNL : 0;
                str += '<tr csnl>';
				str += '<td style="text-align:right;width:100%;"><input name="licshgnl" autocomplete="off" style="border-style:hidden;width:65px;margin:0;padding:0;background-color:white" disabled value="' + value + '" /></td>';
                //str += '<td style="text-align:right;width:100%;">' + value + '</td>';
                str += '</tr>';
            }
        }

        str += '</table>';


       // str = '<td><table style="border-style:hidden;width:100%;margin:0;"> <tr jh><td style="text-align:center">0290501</td></tr><tr jh><td style="text-align:center">0290502</td></tr><tr jh><td style="text-align:center">0290503</td></tr></table></td>';
        return str;
    }


    //保存数据
    function SaveData(yhh) {
        var obj_jh = $("#ContentList1 tbody").find(".datarow[vid=" + yhh + "]").find("[jh]");
        var obj_hgjh = $("#ContentList1 tbody").find(".datarow[vid=" + yhh + "]").find("[hgjh]");
        var obj_csnl = $("#ContentList1 tbody").find(".datarow[vid=" + yhh + "]").find("[csnl]");

        var arr1 = new Array(); var arr2 = new Array(); var arr3 = new Array();
        // alert(arr1.length);
        for (var i = 0; i < obj_jh.length; i++) {
            arr1[i] = obj_jh[i].innerText;
            arr2[i] = obj_hgjh.find("input")[i].value;
            arr3[i] = obj_csnl.find("input")[i].value;
        }

        //
        var res = "1";
        //保存井相关信息

        $.ajax({
            type: "post",
            cache: false,
            async: false,
            url: "/ashx/QSSFZW/HuiGuanTF.ashx",
            data: {
                "op": "SAVE1",
                "y": Y,
                "jbh": arr1.join(','),
                "hgjh": arr2.join(','),
                "csnl": arr3.join(','),
                "userid": userid

            },
            dataType: "text",
            success: function (rs) {
                res = rs;
            },
            error: function (error) {
                layer.msg(error.responseText);
            }
        });


        var hgdj = $("#ContentList1 tbody").find(".datarow[vid=" + yhh + "]").find("[hgdj]").find("input")[0].value;
        var wtsf = $("#ContentList1 tbody").find(".datarow[vid=" + yhh + "]").find("[wtsf]").find("input")[0].value;
        var ytsf = $("#ContentList1 tbody").find(".datarow[vid=" + yhh + "]").find("[ytsf]").find("input")[0].value;
        var ytsf2 = $("#ContentList1 tbody").find(".datarow[vid=" + yhh + "]").find("[ytsf2]").find("input")[0].value;
        var yhzh = $("#ContentList1 tbody").find(".datarow[vid=" + yhh + "]").find("[yhzh]").find("input")[0].value;
        var khyh = $("#ContentList1 tbody").find(".datarow[vid=" + yhh + "]").find("[khyh]").find("input")[0].value;

        //alert(hgdj + ' ' + wtsf + ' ' + ytsf + ' ' + ytsf2);
        //保存用户相关信息
        $.ajax({
            type: "post",
            cache: false,
            async: false,
            url: "/ashx/QSSFZW/HuiGuanTF.ashx",
            data: {
                "op": "SAVE2",
                "y": Y,
                "hgdj": hgdj,
                "wtsf": wtsf,
                "ytsf": ytsf,
                "ytsf2": ytsf2,
                "userid": userid,
                "yhh": yhh,
                "yhzh": yhzh,
                "khyh": khyh

            },
            dataType: "text",
            success: function (rs) {
                res = rs;
            },
            error: function (error) {
                layer.msg(error.responseText);
            }
        });
        if (res == "0") {
            layer.alert("保存成功！");
            GetHJ();
        }

    }
    
    //计算合计
    function GetHJ() {
        var hgjh = 0, hgl = 0, tf1 = 0, tf2 = 0, tf3 = 0, nhgnl = 0, xhgnl = 0, cshgnl = 0, HGTFHJ=0; var num;
        //hgjh= $("#ContentList1>tbody>tr").find("input[name='lihgjh']").val();
        var dj = 0;
        $("#ContentList1>tbody>tr").each(function () {
            var djEl = $(this).find("td[hgdj] input");
            if (djEl.length) {
                var val = djEl.val();
                if (val.length) { 
                    console.log(val);
                    dj = parseFloat(val);
                }
            }
            //回灌计划
            $(this).find("input[name='lihgjh']").each(function () {
                num = parseFloat($(this).val());
                if (num != NaN && $.trim(num) != "" && num != null && !isNaN(num)) {
                    HGTFHJ += num * dj;
                    hgjh += num;
                }
            });

            //测试回灌能力
            $(this).find("input[name='licshgnl']").each(function () {
                num = parseFloat($(this).val());
                if (num != NaN && $.trim(num) != "" && num != null && !isNaN(num)) {
                    cshgnl += num;
                }
            });

            
            //未退回灌费
            num = parseFloat($(this).find("td[wtsf]").find("input").prop("value"));
            if (num != NaN && $.trim(num) != "" && num != null && !isNaN(num)) {
                tf1 += num;
            }
            //已退回灌费
            num = parseFloat($(this).find("td[ytsf]").find("input").prop("value"));
            if (num != NaN && $.trim(num) != "" && num != null && !isNaN(num)) {
                tf2 += num;
            }
            //预退回灌费
            num = parseFloat($(this).find("td[ytsf2]").find("input").prop("value"));
            if (num != NaN && $.trim(num) != "" && num != null && !isNaN(num)) {
                tf3 += num;
            }

            //回灌量
            //alert($(this).find("td[hgl]")[0].innerHTML);

            $(this).find("td[hgl]").each(function (index, element) {
                num = parseFloat($(element)[0].innerHTML);
                if (num != NaN && $.trim(num) != "" && num != null && !isNaN(num)) {
                    hgl += num;
                }
            });
            //年回灌能力
            $(this).find("td[nhgnl]").each(function (index, element) {
                num = parseFloat($(element)[0].innerHTML);
                if (num != NaN && $.trim(num) != "" && num != null && !isNaN(num)) {
                    nhgnl += num;
                }
            });

            //现回灌能力
            $(this).find("td[xhgnl]").each(function (index, element) {
                num = parseFloat($(element)[0].innerHTML);
                if (num != NaN && $.trim(num) != "" && num != null && !isNaN(num)) {
                    xhgnl += num;
                }
            });

        })
        $("#ipHGJH").attr("value", hgjh.toFixed(4));
        $("#ipHGL").attr("value", hgl);
        $("#ipNHGNL").attr("value", nhgnl.toFixed(4));
        $("#ipXHGNL").attr("value", xhgnl.toFixed(2));
        $("#ipCSHGNL").attr("value", cshgnl.toFixed(2));

        $("#ipWTHGF").attr("value", tf1.toFixed(4));
        $("#ipYTHGF").attr("value", tf2.toFixed(4));
        $("#ipYTHGF2").attr("value", tf3.toFixed(4));

        console.log(HGTFHJ);
        $("#ipHGTFHJ").attr("value", HGTFHJ.toFixed(4));
    }

    //刷新数据
    $("#aSX").click(function () {
        $.ajax({
            type: "post",
            cache: false,
            async: false,
            url: "/ashx/QSSFZW/HuiGuanTF.ashx",
            data: {
                "op": "SXSJ",
                "y": Y
            },
            dataType: "text",
            success: function (rs) {
                if (true) {
                    layer.alert("刷新成功！");
                }

            },
            error: function (error) {
                layer.msg(error.responseText);
            }
        });
    });
    
    //打印账单
    $("#oPrint").click(function () {
        var checks = $("#ContentList1 tbody").find("input[type='checkbox']:checked");
        var yhh;
        var yhhArr = new Array();
        if (checks.length == 0) {
            layer.alert('请选择一条记录进行打印！');
        }
        else {
            $(checks).each(function () {
                yhh = $(this)[0].attributes.vid.value;
                yhhArr.push(yhh);
            });
            //alert(yhhArr);
           
        }

        //var fphms = getFaPiaoHM($(checks).length);
        //fphmsArr = fphms.split(",");
        /////////////////
        //取得报表参数 
        var bbid = 100220;
        bbtitle = "用户退款通知单";
        //var date = new Date();
        //var printdate = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
        //alert(printdate);
        //var returndate = addDate(printdate, 30);
        var params = new Array();
        params[0] = "V_BS:1";
        params[1] = "V_YHHS:" + yhhArr;
       
        // var url = "/Pages/YongShui/15.BaoBiaoGL/BaoBiaoView.aspx?x=-3.4&y=-2&baobiaoid=" + bbid + "&baobiaocs=" + params.join("|");
       
        wap.common.printjx('ZhangDanDY', [
            { key: 'QUERYPARAM', value: params.join("|") },
            { key: 'BAOBIAOID', value: bbid },
            { key: 'USERINFO', value: "csms" }
        ]);


        layer.alert("请确认打印状态!", {
            closeBtn: false,
            btn: ['成功', '打坏', '未打印'],
            btn1: function (index) {
                    $.ajax({
                        type: "post",
                        cache: false,
                        async: false,
                        url: "/ashx/QSSFZW/HuiGuanTF.ashx",
                        data: {
                            "op": "SAVEFPJL",
                            "yhhs": yhhArr.join(","),
                            "zt": 1,
                            "userid": userid
                        },
                        dataType: "text",
                        success: function (rs) {
                            //if (rs == "0") {
                            //    layer.alert("保存成功！");
                            //}
                            for (var i = 0; i < yhhArr.length; i++) {
                                $("#ContentList1 tbody").find(".datarow[vid=" + yhhArr[i] + "]").find("input[type='checkbox']").prop("disabled", "disabled");
                                $("#ContentList1 tbody").find(".datarow[vid=" + yhhArr[i] + "]").find("input[type='checkbox']").removeProp("checked");
                                $("#ContentList1 tbody").find(".datarow[vid=" + yhhArr[i] + "]").css("background-color", "#f6f6f6");
                            }
                            form.render("checkbox");
                        },
                        error: function (error) {
                            layer.msg(error.responseText);
                        }
                    });
              
                layer.close(index);
            },
            btn2: function (index) {
                $.ajax({
                    type: "post",
                    cache: false,
                    async: false,
                    url: "/ashx/QSSFZW/HuiGuanTF.ashx",
                    data: {
                        "op": "SAVEFPJL",
                        "yhhs": yhhArr.join(","),
                        "zt": 0,
                        "userid": userid
                    },
                    dataType: "text",
                    success: function (rs) {
                        //if (rs == "0") {
                        //    layer.alert("保存成功！");
                        //}
                    },
                    error: function (error) {
                        layer.msg(error.responseText);
                    }
                });

                layer.close(index);
            },
            btn3: function (index) {

            }
        });





    });



    function getFaPiaoHM(length) {


    }

    form.on("checkbox(selectAll)", function (data) {
        if (data.elem.checked) {
            $("#ContentList1 tbody tr:visible").find("[name='liCheck']").not("[disabled='disabled']").prop("checked", "checked");
        }
        else {
            $("#ContentList1 tbody tr:visible").find("[name='liCheck']").not("[disabled='disabled']").removeProp("checked");
        }
        form.render("checkbox");
        countSelected();
    });


    //计算选中条数
    function countSelected() {

        $("#lsSelectedCount").text($("#ContentList1 tbody tr:visible").find("[name='liCheck']:checked").length);
    }



    $('#oEdit').click(function () {
        var yhh = $(".datarow[selected='selected']").attr('vid');
        //alert(yhh);
        $('#editcontent').css('display', 'block');
        $("#editcontent2").html('');
        var str = '<table class="layui-table" style="margin-top:20px;width:80%;margin-left:50px;margin-bottom:50px;">';
        str += '<tr><td style="text-align:right;">用户号：</td><td style="text-align:left;">' + yhh + '</td></tr>';
        
        //str += '<tr>';
        //str += '<td>01200000</td>';
        //str += '<td><input autocomplete="off" style="border-style:hidden;width:55px;margin:0;padding:0;background-color:white" /></td>';
        //str += '<td><input autocomplete="off" style="border-style:hidden;width:55px;margin:0;padding:0;background-color:white" /></td>';
        //str += '</tr>';
        str += '<tr>';
        str += '<td style="text-align:right;">回灌单价：</td>';
        str += '<td hgdj style="text-align:left"><input autocomplete="off" style="width:150px;margin:0;padding:0;background-color:white;height:30px;" /></td>';
        str += '</tr>';
        str += '<tr>';
        str += '<td style="text-align:right;">回灌量：</td>';
        str += '<td hgdj style="text-align:left"><input autocomplete="off" style="width:150px;margin:0;padding:0;background-color:white;height:30px;" /></td>';
        str += '</tr>';
        str += '<tr >';
        str += '<td style="text-align:right;">未退回灌费：</td>';
        str += '<td hgdj style="text-align:left"><input autocomplete="off" style="width:150px;margin:0;padding:0;background-color:white;height:30px;" /></td>';
        str += '</tr>';
        str += '<tr>';
        str += '<td style="text-align:right;">已退回灌费：</td>';
        str += '<td hgdj style="text-align:left"><input autocomplete="off" style="width:150px;margin:0;padding:0;background-color:white;height:30px;" /></td>';
        str += '</tr>';
        str += '<tr>';
        str += '<td style="text-align:right;">预退回灌费：</td>';
        str += '<td hgdj style="text-align:left"><input autocomplete="off" style="width:150px;margin:0;padding:0;background-color:white;height:30px;" /></td>';
        str += '</tr>';
        str += '<tr>';
        str += '<td style="text-align:right;">银行账号：</td>';
        str += '<td hgdj style="text-align:left"><input autocomplete="off" style="width:150px;margin:0;padding:0;background-color:white;height:30px;" /></td>';
        str += '</tr>';
        str += '<tr>';
        str += '<td style="text-align:right;">开户银行：</td>';
        str += '<td hgdj style="text-align:left"><input autocomplete="off" style="width:150px;margin:0;padding:0;background-color:white;height:30px;" /></td>';
        str += '</tr>';
        str += '</table>';
        //str += '<div>';
        //str += ' <button id="oSave" class="layui-btn layui-btn-primary" type="button" style="background-color: #edf6f9; ">保存</button>';
        //str += ' <button id="oGiveUp" class="layui-btn layui-btn-primary" type="button" style="background-color: #edf6f9; ">放弃</button>';
        //str += '</div>';
        $("#editcontent2").append(str);

        //$('#editcontent').html($(".datarow[selected='selected']").html());
    });
        
       
    $('#oGiveUp').click(function () {
        $('#editcontent').css('display', 'none');
    });
});